﻿<phone:PhoneApplicationPage 
    x:Class="Paw.Phone.Pages.LoginPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:converters="clr-namespace:Paw.Phone.Converters"
    d:DataContext="{d:DesignData ../DesignData/LoginPageViewModelSampleData.xaml}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.Projection>
            <PlaneProjection />
        </Grid.Projection>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{StaticResource ApplicationNameString}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="log in" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentGrid" Grid.Row="1" Margin="12,12,0,12">

            <StackPanel Orientation="Vertical">

                <TextBlock Text="Enter your credentials to login into the application." FontSize="{StaticResource PhoneFontSizeMedium}" FontFamily="{StaticResource PhoneFontFamilyNormal}" LineHeight="31" LineStackingStrategy="BlockLineHeight" Foreground="{StaticResource PhoneForegroundBrush}" TextWrapping="Wrap" Margin="12,0,24,24"/>

                <StackPanel Orientation="Vertical">
                    <TextBlock Text="Username" FontSize="{StaticResource PhoneFontSizeNormal}" FontFamily="{StaticResource PhoneFontFamilyNormal}" VerticalAlignment="Top" LineHeight="31" LineStackingStrategy="BlockLineHeight" Foreground="{StaticResource PhoneSubtleBrush}" TextWrapping="Wrap" Margin="12,0,12,-5" />
                    <TextBox x:Name="UserNameTextBox" Text="{Binding UserName, Mode=TwoWay}" KeyUp="OnTextBoxKeyUp" />
                </StackPanel>

                <StackPanel Orientation="Vertical">
                    <TextBlock Text="Password" FontSize="{StaticResource PhoneFontSizeNormal}" FontFamily="{StaticResource PhoneFontFamilyNormal}" VerticalAlignment="Top" LineHeight="31" LineStackingStrategy="BlockLineHeight" Foreground="{StaticResource PhoneSubtleBrush}" TextWrapping="Wrap" Margin="12,0,12,-5" />
                    <PasswordBox x:Name="PasswordBox" Password="{Binding Password, Mode=TwoWay}" KeyUp="OnTextBoxKeyUp" />
                </StackPanel>

                <CheckBox IsChecked="{Binding RememberMe, Mode=TwoWay}" Content="Remember me" Foreground="{StaticResource PhoneForegroundBrush}" />

                <StackPanel Orientation="Horizontal" Margin="0" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}, ConverterParameter=true}">
                    <Button x:Name="LoginButton" Content="log in" Click="OnLoginButtonClick" VerticalAlignment="Top" Width="228" />
                    <HyperlinkButton Content="Install certificate" VerticalAlignment="Center" NavigateUri="{Binding SslCertificateUri}" TargetName="_blank" Visibility="{Binding IsSslCertificateLinkVisisble, Converter={StaticResource VisibilityConverter}}" Margin="12,0,0,0" />
                </StackPanel>

                <Button x:Name="RegisterButton" Content="register" Click="OnRegisterButtonClick" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}, ConverterParameter=true}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="228" />
            </StackPanel>

            <StackPanel Margin="12,0" Orientation="Vertical" VerticalAlignment="Bottom">
                <TextBlock Visibility="{Binding CredentialsError, Converter={StaticResource VisibilityConverter}}" Text="Invalid credentials. Please try again." HorizontalAlignment="Left" TextWrapping="Wrap" />
                <TextBlock Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}}" Text="{Binding Message}" HorizontalAlignment="Left" TextWrapping="Wrap" />
                <ProgressBar Height="20" IsIndeterminate="True" Visibility="{Binding IsBusy, Converter={StaticResource VisibilityConverter}}" />
            </StackPanel>

        </Grid>
    </Grid>

</phone:PhoneApplicationPage>
